package com.baizhi.test;

import com.baizhi.entity.Atm;
import com.baizhi.mapper.AtmMapper;
import com.baizhi.service.AtmService;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

public class testAtm {
    @Test
    public void testMapper(){
        ClassPathXmlApplicationContext cxt = new ClassPathXmlApplicationContext("classpath:/applicationContext.xml");
        AtmMapper atmMapper = (AtmMapper) cxt.getBean("atmMapper");
//        System.out.println("atmMapper = " + atmMapper);
//        List<Atm> atms = atmMapper.selectAll(1, 5);
//        for (Atm a:atms
//             ) {
//            System.out.println("a = " + a);
//        }
//        Atm atm = atmMapper.selectById(1);
//        System.out.println("atm = " + atm);
        Atm atm = new Atm(1, "奥特之父", 50, 6000, 20, 5, "新版奥特之父");
        atmMapper.insertAtm(atm);


    }

    @Test
    public void testService(){
        ClassPathXmlApplicationContext cxt = new ClassPathXmlApplicationContext("classpath:/applicationContext.xml");
        AtmService impl = (AtmService) cxt.getBean("atmServiceImpl");
//        List<Atm> atms = impl.selectAll(1, 5);
//        for (Atm a:atms
//             ) {
//            System.out.println("a = " + a);
//        }
//        Atm atm = impl.selectById(1);
//        System.out.println("atm = " + atm);
        Atm atm = new Atm(37, "奥特之父2", 50, 6000, 20, 5, "新版奥特之父");
//        impl.insertAtm(atm);
//        impl.deleteById(38);
        impl.updateAtm(atm);
    }

}
